
package com.insigma.business.qrcode.common.converter;

import com.insigma.business.qrcode.merchant.dto.search.CareWelfareMerchantDiscountBSearcher;
import com.insigma.business.qrcode.welfare.dto.*;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantDiscountInsertRequest;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantDiscountSearchRequest;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantDiscountUpdateRequest;
import com.insigma.business.qrcode.merchant.entity.CareWelfareMerchantDiscountDO;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CareWelfareMerchantDiscountProviderConverter extends AbstractConverter<CareWelfareMerchantDiscountDTO, CareWelfareMerchantDiscountDO> {

    private final static CareWelfareMerchantDiscountProviderConverter careWelfareMerchantDiscountConverter = new CareWelfareMerchantDiscountProviderConverter();

    private CareWelfareMerchantDiscountProviderConverter(){}

    
    public static CareWelfareMerchantDiscountBSearcher convertRequestSO2Searcher(final CareWelfareMerchantDiscountSearchRequest request){
        final CareWelfareMerchantDiscountBSearcher careWelfareMerchantDiscountBSearcher = new CareWelfareMerchantDiscountBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,careWelfareMerchantDiscountBSearcher);
        return careWelfareMerchantDiscountBSearcher;
    }

    
    public static CareWelfareMerchantDiscountDO convertRequestUO2DO(final CareWelfareMerchantDiscountUpdateRequest careWelfareMerchantDiscountUpdateRequest) {
        final CareWelfareMerchantDiscountDO careWelfareMerchantDiscountDO = new CareWelfareMerchantDiscountDO();
        BeanUtils.copyProperties(careWelfareMerchantDiscountUpdateRequest,careWelfareMerchantDiscountDO);
        
        return careWelfareMerchantDiscountDO;
    }

    
    public static CareWelfareMerchantDiscountDO convertRequestIO2DO(final CareWelfareMerchantDiscountInsertRequest careWelfareMerchantDiscountInsertRequest) {
        final CareWelfareMerchantDiscountDO careWelfareMerchantDiscountDO = new CareWelfareMerchantDiscountDO();
        BeanUtils.copyProperties(careWelfareMerchantDiscountInsertRequest,careWelfareMerchantDiscountDO);
        return careWelfareMerchantDiscountDO;
    }

    
    public static List<CareWelfareMerchantDiscountDTO> convertResponseDOList2DTOList(final List<CareWelfareMerchantDiscountDO> careWelfareMerchantDiscountDOList){
        return careWelfareMerchantDiscountConverter.convertGenericResponseDOList2DTOList(careWelfareMerchantDiscountDOList);
    }

    
    public static CareWelfareMerchantDiscountDTO convertResponseDO2DTO(final CareWelfareMerchantDiscountDO careWelfareMerchantDiscountDO){
        return careWelfareMerchantDiscountConverter.convertGenericResponseDO2DTO(careWelfareMerchantDiscountDO);
    }

    
    @Override
    protected CareWelfareMerchantDiscountDTO doConvertResponseDO2DTO(CareWelfareMerchantDiscountDO careWelfareMerchantDiscountDO) {
        final CareWelfareMerchantDiscountDTO careWelfareMerchantDiscountDTO = new CareWelfareMerchantDiscountDTO();
        try {
            BeanUtils.copyProperties(careWelfareMerchantDiscountDO, careWelfareMerchantDiscountDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return careWelfareMerchantDiscountDTO;
    }

}
